#define  _CRT_SECURE_NO_WARNINGS  1
#include<iostream>
using namespace std;
#include"list.h"

void test_list1()
{
	wjy::list<int> lt1;
	lt1.push_back(1);
	lt1.push_back(2);
	lt1.push_back(3);
	lt1.push_back(4);

	wjy::list<int>::iterator it = lt1.begin();
	while (it != lt1.end())
	{
		cout << *it << " ";
		++it;
	}
	cout << endl;
}

class A
{
public:
	A(int a1 = 1, int a2 = 1)
		:_a1(a1)
		,_a2(a2)
	{
	}
//private:
	int _a1;
	int _a2;
};

void Print(const wjy::list<int>& lt)
{
	wjy::list<int>::const_iterator it = lt.begin();
	while (it != lt.end())
	{
		//*it += 1;
		cout << *it << " ";
		++it;
	}
	cout << endl;
}
void test_list2()
{
	wjy::list<A> lt1;
	lt1.push_back({ 1,1 });
	lt1.push_back({ 2,2 });
	lt1.push_back({ 3,3 });
	lt1.push_back({ 4,4 });

	wjy::list<A>::iterator it = lt1.begin();
	while (it != lt1.end())
	{
		//cout << (*it)._a1 << ":" << (*it)._a2 << endl;
		cout << it->_a1 << ":" << it->_a2 << endl;
		++it;
	}

	wjy::list<int> lt2;
	lt2.push_back(1);
	lt2.push_back(2);
	lt2.push_back(3);
	lt2.push_back(4);
	Print(lt2);
}


void test_list3()
{
	wjy::list<int> lt1;
	lt1.push_back(1);
	lt1.push_back(2);
	lt1.push_back(3);
	lt1.push_back(4);
	//lt1.push_back(5);
	//lt1.push_back(6);

	//lt1.insert(lt1.begin(), 100);
	//lt1.insert(lt1.begin(), 20);

	lt1.push_front(5);
	lt1.push_front(6);
	for (auto& e : lt1)
	{
		cout << e << " ";
	}
	cout << endl;

	lt1.pop_back();
	lt1.pop_back();
	for (auto& e : lt1)
	{
		cout << e << " ";
	}
	cout << endl;

	lt1.pop_front();
	lt1.pop_front();
	for (auto& e : lt1)
	{
		cout << e << " ";
	}
	cout << endl;

	lt1.pop_front();
	lt1.pop_front();
	lt1.pop_front();
	for (auto& e : lt1)
	{
		cout << e << " ";
	}
	cout << endl;

}

void test_list4()
{
	wjy::list<int> lt1;
	lt1.push_back(1);
	lt1.push_back(2);
	lt1.push_back(3);
	lt1.push_back(4);
	
	wjy::list<int> lt2(lt1);
	for (auto& e : lt2)
	{
		cout << e << " ";
	}
	cout << endl;

	wjy::list<int> lt3;
	lt3.push_back(10);
	lt3.push_back(20);
	lt3.push_back(30);
	lt3.push_back(40);
	lt3.push_back(50);

	lt1 = lt3;
	for (auto& e : lt1)
	{
		cout << e << " ";
	}
	cout << endl;
}

void test_list5()
{
	wjy::list<int> lt1 = { 10,20,30,40,50 };
	for (auto& e : lt1)
	{
		cout << e << " ";
	}
	cout << endl;
}
int main()
{
	test_list5();
	return 0;
}